package sketch.generator;

import java.util.Collections;
import java.util.List;

public class SingleValueGenerator<T> extends ValueGenerator<T> {

	private T value;
	
	public SingleValueGenerator(T value) {
		this.value = value;
	}

	//XXX is this really useful?
	@Override
	public T composeData() {
		throw new UnsupportedOperationException("composeData() is not supported in SingelValueGenerator yet!");
	}

	@Override
	protected T generateNext() {
		if(!isReset()) {
			throw new IterationException("forget to call reset() for literal value!");
		}
		return this.value;
	}

	@Override
	public boolean hasNext() {
		return isReset();
	}

	@Override
	public List<T> nextWrappedValue() {
		T t = this.generateNext();
		return Collections.singletonList(t);
	}

}